import request from '@/config/axios'

// 功能室 VO
export interface RoomVO {
  id: number // 编号
  name: string // 功能室名称
  schoolCode: string // 所属园区
  roomType: string // 类型
  scheduleRule: string //排期规则
  appleRule: string //申请规则
  teamIds: string //负责组别IDs
  teamNames: string //负责组别
  sort: number // 排序
  remark: string // 备注
  status: number // 状态
}

// 功能室 API
export const RoomApi = {
  // 查询功能室分页
  getRoomPage: async (params: any) => {
    return await request.get({ url: `/school/room/page`, params })
  },

  //查询功能室列表（树形结构，提供给级联选择器）
  getRoomList: async (roomType: string) => {
    return await request.get({ url: `/school/room/tree?roomType=` + roomType })
  },

  // 查询功能室详情
  getRoom: async (id: number) => {
    return await request.get({ url: `/school/room/get?id=` + id })
  },

  // 新增功能室
  createRoom: async (data: RoomVO) => {
    return await request.post({ url: `/school/room/create`, data })
  },

  // 修改功能室
  updateRoom: async (data: RoomVO) => {
    return await request.put({ url: `/school/room/update`, data })
  },

  // 删除功能室
  deleteRoom: async (id: number) => {
    return await request.delete({ url: `/school/room/delete?id=` + id })
  },

  // 导出功能室 Excel
  exportRoom: async (params) => {
    return await request.download({ url: `/school/room/export-excel`, params })
  },

  // ==================== 子表（功能室设备） ====================

  // 获得功能室设备分页
  getRoomEquipmentPage: async (params) => {
    return await request.get({ url: `/school/room/room-equipment/page`, params })
  },
  // 新增功能室设备
  createRoomEquipment: async (data) => {
    return await request.post({ url: `/school/room/room-equipment/create`, data })
  },

  // 修改功能室设备
  updateRoomEquipment: async (data) => {
    return await request.put({ url: `/school/room/room-equipment/update`, data })
  },

  // 删除功能室设备
  deleteRoomEquipment: async (id: number) => {
    return await request.delete({ url: `/school/room/room-equipment/delete?id=` + id })
  },

  // 获得功能室设备
  getRoomEquipment: async (id: number) => {
    return await request.get({ url: `/school/room/room-equipment/get?id=` + id })
  }
}
